package io.sage.modules.query.controller;

import com.github.pagehelper.PageHelper;
import io.sage.common.utils.R;
import io.sage.modules.outwarehouse.entity.BEmployeeAccessRecord;
import io.sage.modules.query.entity.BWeather;
import io.sage.modules.query.enums.BWeatherEnum;
import io.sage.modules.query.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zxh
 * @Title: ObservatoryController
 * @ProjectName sage_wms
 * @Description: TODO
 * @date 2019/8/1418:45
 */
@RestController
@RequestMapping("sage/observatory")
public class ObservatoryController {
    @Autowired
    private WeatherService weatherService;
    /**
     * 按照天查询当前天气如何
     *
     * @return R
     */
    @GetMapping(value = "/queryWeather")
    @ResponseBody
    public R queryAll() {
        BWeather bWeather=new BWeather();
        PageHelper.startPage(1, 1);
        List<BWeather> list=weatherService.selectByBWeather(bWeather);
        bWeather=list.size()>0?list.get(0):null;
        if(bWeather!=null){
            bWeather.setSkyconsName(BWeatherEnum.getMessage(bWeather.getSkycons()));
        }
        return R.ok().put("date", bWeather);
    }

}
